//
//  YDListViewModel.h
//  IngCard
//
//  Created by kf on 2017/5/23.
//  Copyright © 2017年 IngDan. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "YDBaseTableViewController.h"
#import "YDBaseView.h"
#import "YDBaseTableViewCell.h"

@protocol YDTableViewModelDelegate <NSObject>
- (void) onViewModelChanged;
@end

@interface YDSectionDataSource : NSObject
@property(nonatomic, strong) id<YDViewDataSource> headerDataSource;
@property(nonatomic, strong) id<YDViewDataSource> footerDataSource;

-(void) insertViewDataSource:(id<YDViewDataSource>) dataSource;
- (void) addViewDataSource:(id<YDViewDataSource>) dataSource;

- (BOOL) removeDataSource:(id<YDViewDataSource>) dataSrouce;

- (void) replaceDataSource:(id<YDViewDataSource>) oldDataSource
             newDataSource:(id<YDViewDataSource>) newDataSrouce;

- (NSInteger) indexOfDataSource:(id<YDViewDataSource>) dataSource;

- (id<YDViewDataSource>) dataSourceAtIndex:(NSInteger) index;

- (NSInteger) countOfRows;
@end

@interface YDTableViewDataSource : NSObject

- (instancetype)initWithTableView:(UITableView *) tableView;

- (NSIndexPath *)indexPathOfDataSource:(id<YDViewDataSource>) dataSource;

- (NSInteger) numberOfSections;

- (NSInteger) numberOfRowsWithSectionIndex:(NSInteger) sectionIndex;


/**
 增、删、改、查DataSource
 */
- (void) insertDataSource:(Class) dataSourceClassName
                atSection:(NSInteger) sectionIndex
                   config:(void (^)(id<YDViewDataSource> dataSource)) config;

- (void) addDataSource:(Class) dataSourceClassName
             atSection:(NSInteger) sectionIndex
                config:(void (^)(id<YDViewDataSource> dataSource)) config;

- (void) deleteDataSource:(YDBaseTableViewCellDataSrouce *) dataSource;

- (void) deleteDataSourceByIndexPath:(NSIndexPath *) indexPath;

- (void) reloadDataSource:(YDBaseTableViewCellDataSrouce *) dataSource;

- (void) reloadDataSourceByIndexPath:(NSIndexPath *) indexPath;

- (void) replaceDataSource:(YDBaseTableViewCellDataSrouce *) oldDataSource
                    config:(void (^)(id<YDViewDataSource> newDataSource)) config;

- (id<YDViewDataSource>) dataSourceAtIndexPath:(NSIndexPath *) indexPath;


/**
 增、删、改、查sectionHeaderDataSource、sectionFooterDataSource
 */
- (void) setSectionHeaderDataSource:(Class) dataSourceClassName
                          atSection:(NSInteger) sectionIndex
                             config:(void (^)(id<YDViewDataSource> dataSource)) config;

- (void) setSectionFooterDataSource:(Class) dataSourceClassName
                          atSection:(NSInteger) sectionIndex
                             config:(void (^)(id<YDViewDataSource> dataSource)) config;

- (id<YDViewDataSource>) headerDataSourceAtIndexPath:(NSUInteger) index;

- (id<YDViewDataSource>) footerDataSourceAtIndexPath:(NSUInteger) index;

@end
